<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@page session="true"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/pages/util/configurationPage.jsp"/>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/css/jquery.dataTables.css">
    <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/js/jquery.js"></script>
    <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/js/jquery.dataTables.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            var adjusted1 = false;
            $('#listTable').dataTable( {
                language: {"url": "<%=request.getContextPath()%>/static/DataTables-1.10.4/Polish.json"},
                processing: true,
                ajax: "getAccountsList",
                columns: [
                    {"title":"Nr konta", "data": "number" },
                    //{"title":"Imię", "data": "user.firstName" },
                    //{"title":"Nazwisko", "data": "user.lastName" },
                    //{"title":"Login", "data": "username" },
                    {"title":"Saldo", "data": "balance" },
                    {"title":"Konto", "data": "segment" },
                    {"title":"Akcje", "data": "number" }
                ],
                columnDefs: [
                {
                    "render": function(data, type, row) {
                    var url = "${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}/orbeon/fr/";
                    var stringQuery = "?username=${pageContext.session.getAttribute('com.skb.model.User')}&group=${pageContext.session.getAttribute('com.skb.model.UserDepartment')}";
                    return "<div class='btn-group text-left'>"+
                                "<button type='button' class='btn btn btn-primary dropdown-toggle' data-toggle='dropdown'>"+
                                "<i class='glyphicon glyphicon-cog'></i> Akcje <span class='caret'></span>"+
                                "</button><ul class='dropdown-menu' role='menu'>"+
                                "<li><a href='<c:url value='/user/manageAccount'/>?number=" + data + "'><i class='glyphicon glyphicon-hand-right'></i> Zarządzaj </a></li>"+
                                //"<li><a href='<c:url value='/admin/account/cashWithdrawal'/>?number=" + data + "'><i class='glyphicon glyphicon-log-in'></i> Wypłać gotówkę </a></li>"+
                                //"<li><a href='<c:url value='/admin/account/cachePayment'/>?number=" + data + "'><i class='glyphicon glyphicon-log-out'></i> Wpłać gotówkę </a></li>"+
                                //"<li><a href='<c:url value='/admin/account/deleteAccount'/>?number=" + data + "'><i class='glyphicon glyphicon-trash'></i> Usuń konto </a></li>"+
                            "</ul></div>";
                    },
                    "orderable": false,
                    "className": "do text-center no-sorting",
                    "targets": -1
                },
                {
                    "targets": "_all",
                    "createdCell": function(td, cellData, rowData, row, col) {
                    $(td).attr('role', 'gridcell');
                    },
                }
                ],
            } );
        } );
    </script>
</head>
<body class="bg-body">
    <jsp:include page="./../util/navbar/navbarMain.jsp"/>
    <br>
    <div class="container">
        <div class="row">
            <div class="panel panel-info">
                <div class="panel-heading text-center"><h2><b>Lista moich kont</b></h2></div>
                <br>
                <div class="container">
                    <table id="listTable" class="display table-bordered" cellspacing="0" width="100%"></table>
                </div>
                <br>
                <div class="col-lg-12 text-center hide">
                    <a class="btn btn-success" href="<c:url value="/admin/account/nextMonth"/>" ><i class="glyphicon glyphicon-random"></i> Następny miesiąc </a>
                </div>
                <br>
            </div>
        </div>
    </div>
    <jsp:include page="./../util/footer.jsp"/>
</body>
</html>